import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Location } from '@angular/common';

import { aroAnimation } from '../../../../animation';
import { AccountService } from '../../../../services/account.service';

@Component({
  selector: 'app-reset',
  templateUrl: './reset.component.html',
  styleUrls: ['./reset.component.css'],
  animations: [aroAnimation]
})
export class ResetComponent implements OnInit {

  public readerId: string = localStorage.getItem('ReaderId');

  constructor(private router: Router, private currentRouter: ActivatedRoute, private location: Location,
    private accountService: AccountService) { }

  ngOnInit() {
  }

  public goBack(): void {
    this.location.back();
  }

  public nextStep_onclick(phone, password) {
    // 先修改密码,再跳转发送验证码
    this.accountService.reset(this.readerId, password).subscribe(res => {
      if (res.Code == 100) {

        this.router.navigate(['./code', phone]);
      }
    });

  }

}
